package com.example.mymvvmdemo.net.presenter;



import com.example.mymvvmdemo.MyApplication;
import com.example.mymvvmdemo.net.model.IModel;
import com.example.mymvvmdemo.net.model.PutModel;
import com.example.mymvvmdemo.net.view.IView;
import com.example.mymvvmdemo.utils.LogUtils;

import java.util.HashMap;

/**
 * 普通Put请求统一presenter
 */
public class PutPresenter implements IModel.PutModel {

    private PutModel putModel = new PutModel(this);

    private IView.PutView putView;

    public PutPresenter(IView.PutView putView) {
        this.putView = putView;
    }

    public void startLoadPut(String url, HashMap<String, String> hashMap, String type) {
        putModel.startLoadPut(url, MyApplication.getAuthToken(), hashMap, type);
    }


    //回调给view
    @Override
    public void loadPutSuccess(String result, String type) {
        LogUtils.d("load put success type:" + type + ",result:" + result);
        LogUtils.printJson(result, type);
        putView.loadPutSuccess(result, type);
    }

    @Override
    public void loadPutFail(String message, String type) {
        LogUtils.d("load put fail type:" + type + ",message:" + message);
        putView.loadPutFail(message, type);
    }

    @Override
    public void loadPutAccountError(int code) {
        LogUtils.d("load put account error code :" + code);
        putView.loadPutAccountError(code);
    }

    @Override
    public void loadPutNetWorkError(String message) {
        LogUtils.d("load put network error :" + message);
        putView.loadPutNetWorkError();
    }

}
